#ifndef CGRAPHICSCONTEXT_H_INCLUDED
#define CGRAPHICSCONTEXT_H_INCLUDED

/**
 *
 * \file CGraphicsContext.h
 * \brief This file contains the CGraphicsContext class declaration.
 * \author Vladimir Klubkov (aka marked)
 *
 * Last changes date:
 * \date 13.03.2011
 *
 * Copyright 2011 Vladimir Klubkov <marked-one@yandex.ru>
 *
 * This file is part of OOXlib.
 *
 * OOXLib is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * OOXlib is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with OOXlib; if not, you can try to find  it here:
 * http://www.gnu.org/licenses/gpl.txt
 * or write to the Free Software Foundation, Inc., 59 Temple Place,
 * Suite 330, Boston, MA  02111-1307  USA
 *
 */

#include "IWindow.h"
#include "shapes.h"
#include "CColor.h"
#include "CPixmap.h"

namespace OOXlib {

/**
 * \class CGraphicsContext
 * Class, which represents window graphics context.
 */
// \todo (marked#1#): Add other functionality (computations, draws etc).
class CGraphicsContext {
public:
    /**
     * \class CNULLPtrIWindowException
     * Exception handler class.
     */
    class CNULLPtrIWindowException : public CException {
    public:
        CNULLPtrIWindowException(const ::std::string &File, const int iLine, const ::std::string &Function);
    };
    /**
     * \class CXQueryFontException
     * Exception handler class.
     */
    class CXQueryFontException : public CException {
    public:
        CXQueryFontException(const ::std::string &File, const int iLine, const ::std::string &Function);
    };
public:
// Constructor.
    CGraphicsContext(const CXServerConnection *pXServerConnection, const IWindow* pWindow);
// Destructor.
    ~CGraphicsContext();
// Set.
    void SetForegroundColor(const CColor *pColor);
    void SetBackgroundColor(const CColor *pColor);
    void SetText(const ::std::string &Text);
// Compute.
    unsigned int ComputeTextLineHeight();
    ::std::vector<unsigned int> ComputeCharactersWidths();
    CUInt2dRectangle ComputeTextRectangle();
// Draw.
    void DrawLine(const CUInt2dLine &Line);
    void DrawRectangle(const CUInt2dRectangle &Rectangle);
    void DrawFilledRectangle(const CUInt2dRectangle &Rectangle);
    void DrawText(const CUInt2dPoint &Position);
    void DrawPixmap(const CPixmap &Pixmap, const CUInt2dPoint &Position);
private:
    CGraphicsContext(const CGraphicsContext &Other);
    CGraphicsContext& operator=(const CGraphicsContext &Other);
private:
    const CXServerConnection *m_pXServerConnection;
    const IWindow *m_pWindow;
    ::GC m_GC;
    ::std::vector< ::std::string> m_Text;
};

} // OOXlib

#endif // CGRAPHICSCONTEXT_H_INCLUDED
